#ifndef __PUBLIC_H__
#define __PUBLIC_H__

#include "data_struct.h"

void INSERTION_SORT(void *base, size_t nmemb, size_t size, 
		int (*compar)(const void *, const void *));
void INSERTION_SORT_BINARY_SEARCH(void *base, size_t nmemb, size_t size,
		int (*compar)(const void *, const void *));
void *BINARY_SEARCH_ALL(void *base, size_t nmemb, size_t size, const void *searchmem, 
		int (*compar)(const void *, const void *));
void MERGE_SORT(void *base, size_t nmemb, size_t size,
		int (*compar)(const void *, const void *));
void HEAP_SORT(void *base, size_t nmemb, size_t size,
		int (*compar)(const void *, const void *));

#define BINARY_SEARCH(base, nmemb, size, searchmem, compar) \
({\
	void *p = BINARY_SEARCH_ALL(base, nmemb, size, searchmem, compar);\
	if (compar(searchmem, p))\
		p = NULL; \
	p;\
})

#endif
